POV-Ray : Newsgroups : povray.general : Math Question : Re: Math Question Server Time
10 Aug 2024 15:17:57 EDT (-0400)
  Re: Math Question  
From: mr art
Date: 2 Dec 1999 11:22:38
Message: <38469CB9.D481A3FA@gci.net>
I had a simular problem with eyes and looking
at one spot. this is a solution.
given	P1,P2 are location vectors
	angle functions return radian values
	degrees() accepts radians and returns degrees
 
Use the function vnormalize(P2-P1) to return a vector of
	unit lingth that points from P1 to P2.
Use -degrees(asin(z componant)) and  degrees(asin(y componant)) 
	to return the amount of degrees that the object must be
	rotated while at P2 to face P1.
This assumes that the object is "facing" in the -x direction.

I have used a macro to keep the intent of the code clear.
I hope this helps. It gave me good results in making a
mannequin look at the camera.

#macro v_lookat(P1,P2)
	#local Norm=(vnormalize(P2-P1));
	<0,-degrees(asin(Norm.z)),degrees(asin(Norm.y))>
#end

#declare CameraPosition <-35,67,-16>;
#declare PicturePosition <2,-1,3>;
object	{
	Picture 
	rotate v_lookat( CameraPosition , PicturePosition )
	translate PicturePosition
	}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.